tar -xf 常用工具包.tgz
cd /root/k8s/常用工具包
yum -y localinstall *.rpm

#配置时间同步
# 添加阿里时钟服务器
sed -i '6a server ntp1.aliyun.com iburst\nserver ntp2.aliyun.com iburst' /etc/chrony.conf

# 启动服务
systemctl start chronyd && systemctl enable chronyd

# 验证
chronyc sources -v  >> /dev/null

#先离线安装docker
tar -xf docker-rpm.tgz
cd /root/k8s/docker-rpm
yum -y localinstall *.rpm
#设置cgroup
cat > /etc/docker/daemon.json << EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
}
EOF
systemctl daemon-reload && systemctl restart docker

#离线安装k8s
tar -xf k8s-v1.23.15-rpm.tgz
cd /root/k8s/k8s-v1.23.15-rpm
yum -y localinstall *.rpm
cd ..
导入镜像
tar -xf k8s-v1.23.15-images.tgz
cd /root/k8s/k8s-v1.23.15-images
#列出当前文件所有镜像名
for i in `ls`; do echo $i; done
#用docker load 批量导入k8s镜像
for i in `ls`; do docker load -i $i; done
#以上步骤master和worker都执行

#以下步骤在master执行
#初始化集群，从而可以执行kubectl
kubeadm init --config=kubeadm-config.yaml
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl create -f calico.yaml

kubeadm certs check-expiration		#检查k8s的证书有没有过期
kubeadm certs renew
#设置开机自启
systemctl enable --now kubelet

#在worker执行，加入集群
kubeadm join 192.168.42.132:6443 --token abcdef.0123456789abcdef --discovery-token-ca-cert-hash sha256:cc2ba94f830caeb8ed8e7a381dfc2b21b435d8d261b7cbd2a3d547645d6924ff
#设置开机自启
systemctl enable --now kubelet

#在到master
kubectl  get pods -A  -w
kubectl get nodes